#include<iostream>
using namespace std;
int main ()
{
    int M,k;
	long num;
    cin >> M;
    while(M--){
        cin >> k;
        for(int i=1; i<11; i++) {
            num = i*k*k;
            string number = to_string(num), sk = to_string(k);
            if(sk == number.substr(number.size() - sk.size())){
            	cout << i << " " << num << endl;
            	break;
			}
            else if(i == 10)
                printf("No\n");
        }
    }
    return 0;
}
